using System;
using FtpLib;

namespace Quiki.Services
{
    public class FtpLibFtpConnection : IFtpConnection
    {
        [CLSCompliant(false)]
        public FtpLibFtpConnection(FtpConnection connection)
        {
            this.connection = connection;
        }

        public void ChangeDirectory(string directory)
        {
            connection.SetCurrentDirectory(directory);
        }

        public void CreateDirectory(string directory)
        {
            connection.CreateDirectory(directory);
        }

        public bool DirectoryExists(string directory)
        {
            return connection.DirectoryExists(directory);
        }

        public void PutFile(string localFileName, string remoteFileName)
        {
            connection.PutFile(localFileName, remoteFileName);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (false == disposed)
            {
                // clean native resources         

                if (disposing)
                {
                    // clean managed resources            
                    if (connection != null)
                        connection.Dispose();
                }

                disposed = true;
            }
        }

        private bool disposed;
        private readonly FtpConnection connection;
    }
}